package com.waimai1.waimai.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.waimai1.waimai.common.BaseContext;
import com.waimai1.waimai.dao.CouponDao;
import com.waimai1.waimai.entity.Coupon;
import com.waimai1.waimai.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

/**
 * (Coupon)表服务实现类
 *
 * @author makejava
 * @since 2023-11-01 17:21:28
 */

@Service("couponService")
public class CouponServiceImpl extends ServiceImpl<CouponDao, Coupon> implements CouponService {
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public Long getRedisWhite(String id){
        return redisTemplate.opsForSet().size(BaseContext.getAcid()+":"+id);
    };
    @Override
    public Boolean hasMember(String key,String phone){
        return redisTemplate.opsForSet().isMember(BaseContext.getAcid()+":"+key,phone);
    }
    @Override
    public void clearCouponWhiteRedis(String wexinNo){
        redisTemplate.delete(BaseContext.getAcid()+":couponPersonWhite"+wexinNo);
    }
}

